#ifndef BATTLEGROUP_H
#define BATTLEGROUP_H

#include <QWidget>
#include "tableView/tableviewheader.h"
#include <QStandardItemModel>
#include "group.h"
#include "QTime"


namespace Ui {
class BattleGroup;
}
typedef struct GROUP_USER_TABLE_DATA_T
{
    int ID;//序号
    QString nNo;//用户名
    QString sName;//用户姓名

}GROUP_USER_TABLE_DATA;

typedef QHash<QString, GROUP_USER_TABLE_DATA> QHashUserTable_GROUP;
typedef QHash<QString, GROUP_USER_TABLE_DATA>::iterator QHashUserTableIterator_Group;
class BattleGroup : public QWidget
{
    Q_OBJECT
    enum COLUMN_NUM_E
    {
        COLUMN_CHECKBOX = 0,
        COLUMN_NO,
        COLUMN_IP,
        COLUMN_ID,
        COLUMN_NAME,
        COLUMN_SEX,
        COLUMN_AGE,
        COLUMN_DEVICE

    };

public:
    explicit BattleGroup(QWidget *parent = nullptr);
    ~BattleGroup();
//    void initServer();
    void paintEvent(QPaintEvent *event);
    void initTableView_All();
    void initTableView_AllData();
    void initTableView_A();
    void initTableView_B();
    void initTableView_C();
    void initTableView_D();
    void setColumnWidth();
    void RefreshTable();
    void RefreshTableA();
    void RefreshTableB();
    void RefreshTableC();
    void RefreshTableD();
    QList<int>  generateUniqueRandomNumber(int userNums);

private:
    Ui::BattleGroup *ui;
    TableViewHeader *m_pTableHeader_All;
    QStandardItemModel *m_pTableModel_All;

    TableViewHeader *m_pTableHeader_Chlid;
    QStandardItemModel *m_pTableModel_A,*m_pTableModel_B,*m_pTableModel_C,*m_pTableModel_D;
    int m_nCheckedCount_All;//选中个数
    QHashUserTable m_userTableHash;
    QHashUserTable m_userTableHash_A;
    QHashUserTable m_userTableHash_B;
    QHashUserTable m_userTableHash_C;
    QHashUserTable m_userTableHash_D;

private slots:
    void on_tableViewClick(QModelIndex nIndex);
    void on_tableViewDbClick(QModelIndex nIndex);
    void on_tableViewSort(int nColumn);
    void on_tableViewSelectAllCheckBoxClick(Qt::CheckState state);
    void on_tableViewADbClick(QModelIndex nIndex);
    void on_tableViewBDbClick(QModelIndex nIndex);
    void on_tableViewCDbClick(QModelIndex nIndex);
    void on_tableViewDDbClick(QModelIndex nIndex);

    void on_pb_A_clicked();
    void on_pb_B_clicked();
    void on_pb_C_clicked();
    void on_pb_D_clicked();
    void on_pushButton_exit_clicked();
    void on_pb_random_clicked();
    void on_pb_enter_clicked();

    void getUserTableInfo(QHashUserTable m_user);
signals:
    void command_toClient(int type,QJsonObject json);
    void SendUserTableInfo(QHashUserTable m_userTableHash);
    void SendUserTableInfoABCD(QHashUserTable a,QHashUserTable b, QHashUserTable c,QHashUserTable d);
};

#endif // BATTLEGROUP_H
